// 产品管理中心 - 所有产品数据都在这里统一管理
export const productData = [
  {
    id: 1,
    name: '权限管理系统',
    code: 'PROD-001',
    category: '基础设施',
    status: '开发中',
    progress: 75,
    manager: '李工程师',
    description: '统一权限管理平台，支持RBAC权限模型',
    startDate: '2023-01-15',
    endDate: '2023-06-30',
    createdAt: '2023-01-15'
  },
  {
    id: 2,
    name: '用户中心',
    code: 'PROD-002',
    category: '核心服务',
    status: '测试中',
    progress: 90,
    manager: '王开发',
    description: '统一用户认证和用户信息管理平台',
    startDate: '2023-02-10',
    endDate: '2023-05-15',
    createdAt: '2023-02-10'
  },
  {
    id: 3,
    name: '支付平台',
    code: 'PROD-003',
    category: '核心服务',
    status: '规划中',
    progress: 30,
    manager: '张产品',
    description: '统一支付接入平台，支持多种支付方式',
    startDate: '2023-03-05',
    endDate: '2023-09-30',
    createdAt: '2023-03-05'
  },
  {
    id: 4,
    name: '数据分析平台',
    code: 'PROD-004',
    category: '数据服务',
    status: '已上线',
    progress: 100,
    manager: '赵数据',
    description: '大数据分析和可视化平台',
    startDate: '2023-01-20',
    endDate: '2023-04-30',
    createdAt: '2023-01-20'
  },
  {
    id: 5,
    name: '消息通知系统',
    code: 'PROD-005',
    category: '基础设施',
    status: '开发中',
    progress: 60,
    manager: '钱工程师',
    description: '统一消息推送和通知服务平台',
    startDate: '2023-02-25',
    endDate: '2023-07-15',
    createdAt: '2023-02-25'
  },
  {
    id: 6,
    name: 'API网关',
    code: 'PROD-006',
    category: '基础设施',
    status: '已上线',
    progress: 100,
    manager: '孙架构',
    description: '统一API网关和流量管理平台',
    startDate: '2023-01-05',
    endDate: '2023-03-31',
    createdAt: '2023-01-05'
  }
];

// 生成更多测试数据
for (let i = 7; i <= 50; i++) {
  const categories = ['基础设施', '核心服务', '数据服务', '应用服务', '其他'];
  const statuses: Array<'规划中' | '开发中' | '测试中' | '已上线'> = ['规划中', '开发中', '测试中', '已上线'];
  const managers = ['李工程师', '王开发', '张产品', '赵数据', '钱工程师', '孙架构', '周设计', '吴测试'];
  
  productData.push({
    id: i,
    name: `产品${i}`,
    code: `PROD-${i.toString().padStart(3, '0')}`,
    category: categories[Math.floor(Math.random() * categories.length)],
    status: statuses[Math.floor(Math.random() * statuses.length)],
    progress: Math.floor(Math.random() * 101),
    manager: managers[Math.floor(Math.random() * managers.length)],
    description: `这是产品${i}的描述信息`,
    startDate: '2023-01-01',
    endDate: '2023-12-31',
    createdAt: '2023-01-01'
  });
}

// 产品进度概览数据
export const productProgressData = [
  { productName: '权限系统', completed: 75, remaining: 25 },
  { productName: '用户中心', completed: 90, remaining: 10 },
  { productName: '支付平台', completed: 30, remaining: 70 },
  { productName: '数据分析', completed: 100, remaining: 0 },
  { productName: '消息系统', completed: 60, remaining: 40 },
  { productName: 'API网关', completed: 100, remaining: 0 },
];

// 产品需求统计数据
export const productRequirementsData = [
  { productName: '权限系统', total: 45, completed: 32, inProgress: 8, pending: 5 },
  { productName: '用户中心', total: 38, completed: 28, inProgress: 6, pending: 4 },
  { productName: '支付平台', total: 52, completed: 15, inProgress: 12, pending: 25 },
  { productName: '数据分析', total: 28, completed: 28, inProgress: 0, pending: 0 },
  { productName: '消息系统', total: 36, completed: 20, inProgress: 10, pending: 6 },
  { productName: 'API网关', total: 22, completed: 22, inProgress: 0, pending: 0 },
];

// 获取产品统计数据
export function getProductStats() {
  const stats = {
    total: productData.length,
    byStatus: {} as Record<string, number>,
    byCategory: {} as Record<string, number>
  };

  productData.forEach(product => {
    // 统计状态
    if (stats.byStatus[product.status]) {
      stats.byStatus[product.status]++;
    } else {
      stats.byStatus[product.status] = 1;
    }

    // 统计分类
    if (stats.byCategory[product.category]) {
      stats.byCategory[product.category]++;
    } else {
      stats.byCategory[product.category] = 1;
    }
  });

  return stats;
}